package com.example.common.utils;

import com.example.common.Statistical;
import org.slf4j.Logger;

public final class Statistics {

    private static final ThreadLocal<Integer> COUNTER = ThreadLocal.withInitial(() -> 0);

    private Statistics() {
        throw new IllegalStateException("Statistic class");
    }

    public static void logInfo(Logger log) {
        logInfo(log, "实例化");
    }

    public static void logInfo(Logger logger, String method) {
        logInfo(logger, method, "");
    }

    public static void logInfo(Logger log, String method, Object info) {
        logInfo(log, () -> {int order = COUNTER.get() + 1; COUNTER.set(order); return order;}, method, info);
    }

    public static void logInfo(Logger log, Statistical statistical, String method, Object info) {
        log.info("顺序 : {}, 方法 : {}, 信息 : {}", statistical.gas(), method, info);
    }

}
